import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { ProTable } from '@ant-design/pro-components';
import {useRef} from 'react';
import {loExtentData} from "@/services/bz/api";

type GithubIssueItem = {
  id: number;
  merchantCode: string;
  status: string;
  webUrl: string;
};

const columns: ProColumns<GithubIssueItem>[] = [
  {
    title: '坐席账号',
    dataIndex: 'agentCode',
    width: 200,
    search:false,
    editable:false
  },
  {
    editable:false,
    title: '展期率',
    key: 'rate',
    dataIndex: 'rate',
    hideInSearch: true,
  }
];

export default () => {
  const actionRef = useRef<ActionType>();
  return (
    <ProTable<GithubIssueItem>
      columns={columns}
      actionRef={actionRef}
      cardBordered
      request={async () => {
        let response = await loExtentData();
        return {data: response.data == null ? [] : response.data};
      }}
      rowKey="id"
      search={{
        labelWidth: 'auto',
      }}
      form={{
        // 由于配置了 transform，提交的参与与定义的不同这里需要转化一下
        syncToUrl: (values, type) => {
          console.log("~~~~")
          if (type === 'get') {
            return {
              ...values,
              created_at: [values.startTime, values.endTime],
            };
          }
          return values;
        },
      }}
      pagination={{
        pageSize: 20,
        onChange: (page) => console.log(page),
      }}
      search={false}
      dateFormatter="string"
      headerTitle={"LO展期率"}
      options={true}
      revalidateOnFocus={false}
    />
  );
};
